/*
============================================================================
 Name        : ShoutcastPlugin.h
 Author      : 
 Version     :
 Copyright   : Your copyright notice
 Description : CShoutcastPlugin declaration
============================================================================
*/

#ifndef __CSHOUTCASTPLUGIN__
#define __CSHOUTCASTPLUGIN__

#include "PluginInterface.h"	//CPluginInterface
#include "ShoutcastPlayer.h"	//MShoutcastPlayerObserver

class CEikMenuPane;
class CShoutcastPlayer;
class CShoutcastUI;

// An implementation of the CPluginInterface definition
class CShoutcastPlugin :		public CPluginInterface, 
								public MShoutcastPlayerObserver

{
public:
	// Standardised safe construction which leaves nothing the cleanup stack.
	static CShoutcastPlugin* NewL(TAny* aInitParams);
	// Destructor	
	~CShoutcastPlugin();

private:
	// Construction
	CShoutcastPlugin(TAny* aParams);
	void ConstructL();


public: //from CPluginInterface
	const TDesC& GetMenuText();
	TInt GetMenuCommand();
	void AddExtraMenu(CEikMenuPane* aMenuPane);
	void HandleCommandL(TInt aCommand);
	void Draw(CWindowGc& aGc, const TRect& aRect) const;
	void SetContainer(MPluginContainer* aContainer);

	void Activate();
	void Deactivate();

	//Colors
	TRgb BackBorderColor() const;
	TRgb BackShadowColor() const;
	TRgb BackColor() const;
	TRgb InsideBorderColor() const;
	TRgb InsideColor() const;
	TRgb ForeColor() const;


public: //from MPluginAdapter
	void PlayL();
	void StopL();
	void PauseL();

	TBool IsReadyToPlay();
	TBool IsReadyToPause() { return EFalse; };
	TBool IsReadyToStop();

	TInt Volume();
	void SetVolume(TInt aVolume);


private: //from MStreamBufferObserver
	void BufferStateChanged(TBool aIsBuffering, TInt aPercent);
	void Finished();

private: //from MShoutcastReaderObserver
	void OnServerNameChanged(const TDesC& aServerName);
	void OnMetadataChanged(const TDesC& aMetadata);


private: //new functions
	void AddResourceFileL();
	void OpenUrlL();
	void StartStreamingL(const TDesC& aUri);


private: //data
	//Plugin state
	enum TState
	{
		EStateNotReady,    //Not ready to play
		EStateReadyToPlay, //Ready to play
		EStatePlaying      //Playing
	} iState;

	// Parameters taken from client
	CPluginInterface::TPluginInterfaceInitParams* iInitParams;

	//Resource compiled file id
	TInt iOffset;

	//Objects that perfom action
	CShoutcastPlayer* iShoutcastPlayer;

	//Server url
	HBufC* iUrl;

	//Metadata
	HBufC* iMetadata;

	//Object that manages UI
	CShoutcastUI* iShoutcastUI;
};  

#endif
